package logic

import (
	"context"
	"srv/model/mysql"
	"srv/model/redis"

	"srv/internal/svc"
	"srv/renrenzu"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodslikeLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodslikeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodslikeLogic {
	return &GoodslikeLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodslikeLogic) Goodslike(in *renrenzu.GoodslikeRequest) (*renrenzu.GoodsListOneResponse, error) {
	// todo: add your logic here and delete this line
	g := []mysql.Goods{}
	mysql.DB.Find(g)
	redis.List(g)
	likes := redis.Likes("like")
	like := []*renrenzu.GoodsList{}
	for _, v := range likes {
		like = append(like, &renrenzu.GoodsList{
			GoodsTitle: v.Member.(string),

			GoodsState: int64(v.Score),
		})
	}
	return &renrenzu.GoodsListOneResponse{List: like}, nil
}
